<template>
  <div class="box">
    <div class="title">
      <div class="el-icon-arrow-left" @click="$router.go(-1)"></div>
      <!--      <div>我的活动</div>-->
      <div>{{ $t('home.Myactivities') }}</div>
      <div @click="$router.push({path:'/listactivitiesHistory'})"
           class="title_right_size">{{ $t('home.History') }}
      </div>
    </div>
    <!-- 查询 -->
    <div class="consume_input">
      <input @focusout="searchUnFocus"
             v-model="searchForm.keyword"
             @change="index"
             @focus="searchFocus"
             class="iconfont"
             :placeholder="showSearchIcon?'\ue630' + $t('home.Search'):''"/>
    </div>
    <!--  记录  -->
    <div v-show="dataList.length>0" style="padding: 15px">
      <div class="card_back" v-for="(info,subIndex) in dataList" :key="subIndex">
        <div class="card_back_left">
          <img src="../../../../assets/static/Consumption/q1.png" alt="">
          <div>
            <div>{{ info.goods_text }}</div>
            <div>{{ info.create_time }}</div>
          </div>
        </div>
        <span v-show="info.is_consume==='1'" style="color: rgba(119, 200, 24,1)">{{ $t('Orders') }}</span>
        <span v-show="info.is_consume!=='1'" style="color: rgba(255, 38, 38,1)">{{ $t('Scan') }}</span>
        <!--        <img v-show="info.is_consume==='1'" src="../../../../assets/static/activitiesHistory/y.png" alt=""/>-->
<!--        <img v-show="info.is_consume!=='1'" src="../../../../assets/static/activitiesHistory/w.png" alt=""/>-->
      </div>
    </div>
    <!-- 无活动时 -->
    <div v-show="dataList.length===0"
         class="col-wrapper"
         style="height: 85vh;justify-content: center">
      <div class="height_flex">
        <div class="height_flex_img">
          <img src="../../../../assets/static/activities/box.png" alt="">
          <div class="height_flex_size">{{ $t('home.Noactivityyet!') }}</div>
          <div>{{ $t('home.PastTransactions') }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {index} from '@/api/merbership/activity'
import '@/styles/flax.css'

export default {
  data() {
    return {
      icon: '\ue630 搜索',
      showSearchIcon: true,
      dataList: [],
      searchForm: {
        yearmonth: undefined,
        keyword: undefined
      }
    }
  },
  activated() {
    this.index()
  },
  methods: {
    /**
     * 查看活动详情
     * @param info
     */
    checkDetail(info) {
      info.is_consume === '1' ? this.$router.push({
        path: '/listConsumptionDetail',
        query: {id: info.id}
      }) : this.$message.info('Scan and open')
    },
    /**
     * 时间戳判断
     * @param timeStamp
     * @returns {string}
     */
    checkTime(timeStamp) {
      let timeStr = new Date(Number(timeStamp))
      return timeStr.toLocaleTimeString()
    },
    /**
     * 按月份查找
     * @param val
     */
    searchYearMonth(val) {
      this.searchForm.yearmonth = String(val.getFullYear()) + '-' + String(val.getMonth() + 1)
      this.index()
    },
    /**
     * 失去焦点时
     */
    searchUnFocus() {
      this.showSearchIcon = true
    },
    /**
     * 搜索框获取焦点时
     */
    searchFocus() {
      this.showSearchIcon = false
    },
    // ------------- axios ---------------------
    /**
     * 我的活动
     */
    index() {
      index(this.$qs.stringify(this.searchForm))
        .then(res => {
          this.dataList = res.data.data.data
        })
    }
  }
}
</script>

<style lang="scss" scoped>

/*  */
.consume_input {
  margin: 15px;
}

.consume_input input {
  box-shadow: 0 0 10px #ccc;
  width: 98%;
  text-align: center;
  outline: none;
  border: none;
  height: 40px;
  border-radius: 10px;
}

.consume_input input::-webkit-input-placeholder {
  color: #67C41D;
}

/* 标题卡 */
.title_card {
  background-color: rgba(193, 225, 169, 0.5);
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #64BE1D;
  border-radius: 10px;
}

.title_card_back {
  background-color: #fff;
  width: 180px;
  /*padding: 8px;*/
  border-radius: 8px;
}

.title_card_back .el-icon-arrow-down {
  margin-left: 3px;
}

/*  */
.card_back {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  margin: 10px 0;
  padding: 10px;
  border-radius: 10px;
}

.card_back img {
  width: 57px;
}

.card_back_left img {
  width: 45px;
  margin-right: 10px;
  margin-top: 5px;
}

.card_back_left {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: #999999;
  font-weight: normal;
}

.card_back_left > div > div:nth-child(1) {
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: bold;
  color: #333333;
}

.box {

  /* 标题 */
  .title {
    background-color: #7ac91b;
    color: #fff;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    font-weight: bold;

    .el-icon-arrow-left {
      float: left;
      margin-top: 5px;
    }

    .title_right_size {
      font-size: 12px;
      font-weight: normal;
    }
  }

  .height_flex {
    //height: 90vh;
    align-self: center;
    display: flex;
    align-items: center;

    .height_flex_img {
      font-size: 11px;
      color: #999;
      width: 100%;
      text-align: center;

      img {
        width: 170px;
      }

      .height_flex_size {
        font-size: 14px;
        color: #333;
        font-weight: bold;
        margin: 20px 0 12px 0;
      }
    }
  }

  /*  */
  .card_back {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    margin: 10px 0;
    padding: 10px;
    border-radius: 10px;
  }

  .card_back img {
    width: 57px;
  }

  .card_back_left img {
    width: 45px;
    margin-right: 10px;
    margin-top: 5px;
  }

  .card_back_left {
    display: flex;
    align-items: center;
    font-size: 11px;
    color: #999999;
    font-weight: normal;
  }

  .card_back_left > div > div:nth-child(1) {
    margin-bottom: 3px;
    font-size: 13px;
    font-weight: bold;
    color: #333333;
  }
}
</style>
